package com.blulioncn.matrix.monitoring.domain;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * 领域模型
 * */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResultDO {

    public int code;
    public String msg;
    public Object data;

    public int getCode() {
        return code;
    }

    private void setCode(int code) {
        this.code = code;
    }


    public String getMsg() {
        return msg;
    }

    private void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    private void setData(Object data) {
        this.data = data;
    }

    public void success(Object data){
        setCode(CODE.SUCCESS);
        setMsg("成功");
        setData(data);
    }

    public void success(String msg){
        setCode(CODE.SUCCESS);
        setMsg(msg);
    }

    public void success(String msg, Object data){
        setCode(CODE.SUCCESS);
        setMsg(msg);
        setData(data);
    }

    public void error(int code){
        setCode(code);
    }

    public void error(int code, String msg){
        setCode(code);
        setMsg(msg);
    }

    public void error(String msg){
        setCode(CODE.ERROR);
        setMsg(msg);
    }

    public interface CODE{
        int SUCCESS = 0;
        int ERROR = 1;
        int ERROR_VERIFY = 2;//验签失败
        int ERROR_LOGIN = 3;//登录失败
        int ERROR_QUERY_PHONE = 4;//登录失败
        int ERROR_REGISTER = 5;//注册失败
        int ERROR_REGISTER_WX = 6;//微信注册失败
        int ERROR_TOKEN = 7;// token错误
        int ERROR_QUERY_NOT_FIND = 9;// 没找到要查询的信息
    }

}
